www.gusucode.com > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序 > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序/tab3_main.m

    function tab3_main(main_fig,ax,tab_name)
% tab1_main file to set up the tab layout.
% main_fig - figure handle
% ax - axis handle
% tab_name - is the name of the tab defined in the main file.
%
  
% The handels of the stuff in the tab are stored in the tabs
% userdata. 
%
% Dirk Tenne 
% CoDE (Control Dynamics and Estimation)
% web:      "http://code.eng.buffalo.edu"
% created:  "05/29/2002"
% modified: "December 12. 2002"
%


% input treatment
    tab = findobj(ax,'string',tab_name); % get the handle of the tab
    if isempty(tab)
      error(['The tab with the tag ''',tab_name,' could not be found!'])
    else
      tab = get(tab,'Userdata');         % and get the handle of the tab
    end

% look for the main figure and axis
  set(main_fig,'CurrentAxes',ax);
  pos = get(ax,'position');
  
% Drawing the setup

% create the tab stuff and store it in hand
  
  txt = 'Hello this is the contents of tab number 3.';
  hand(1) = uicontrol('style','text','string',txt,...
	    'units','normalized','position',[.35 .5 .3 .1]);

% log the handles of the tab1
  set(hand,'Visible','off') % sets the handles initialy to off
  children = get(tab,'Userdata');
  children.inp = hand;
  set(tab,'Userdata',children)